<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String basePath = request.getContextPath();
	String path = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+basePath+"/";
	request.setAttribute("path",path);
%>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<meta name="format-detection" content="telephone=no,address=no,email=no"/>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<title>虎丘婚纱城在线商城</title>
	<script type="text/javascript" src="${path}/mobileTerminal/js/jquery.js"></script>
	<link href="${path}/mobileTerminal/css/style.css" rel="stylesheet" media="all">
	<link rel="shortcut icon" href="${path}/mobileTerminal/img/favicon.png">
</head>
<body class="hu_shopping">
	<header class="home_header">
		<div class="headerwrap">
			<div class="header_wrap">
				<h1>虎丘婚纱城在线商城</h1>
				<div class="header_login">
					<a href="${path}/personal" class="header_login_a"><img style="display:none;" src="${path}/mobileTerminal/img/user_img_08.jpg"></a>
				</div>
			</div>
			<div class="search_wrap">
				 <form id="search_form" name="search_form" action="${path}/frontEndIndex " method="get">
					<input type="submit" value="" name="search_btn" class="search_btn">
					<div class="search_fl">
						<c:if test="${type==0}">
							<input type="text" placeholder="输入搜索内容" name="productName" class="productName" value="没有搜索结果">
						</c:if>
						<c:if test="${type!=0}">
						<input type="text" placeholder="输入搜索内容" name="productName" class="productName" value="${productName}">
						</c:if>
					</div>
				</form>
			</div>
		</div>
	</header><!-- header -->
	<div class="banner_wrap">
		<div class="banner_wrap">
			<c:forEach items="${advertisementList}" var="item">
			<a href="#"><img src="${path}/${item.picture}"></a>
			</c:forEach>
		</div>
	</div><!-- banner_wrap -->
	<div class="content_wrap" id="home_productlist">
		<input type="hidden" id="total_page" name="total_page" value="" />
        <input type="hidden" id="current_page" name="current_page" value="" />
        <input type="hidden" id="aid" name="aid" value="" />
		<ul class="homeul_productlist" id="productlist">
			<c:forEach items="${productList}" var="items">
			<li>
				<a href="${path}/productDetails?productId=${items.id}" class="a_img"><img src="${items.carousel0}"></a>
				<a href="${path}/productDetails?productId=${items.id}" class="a_title">${items.productName}</a>
				<div class="list_price_sales">
					<div class="list_price_num">￥<span class="red_txt">${items.nowPrice}</span></div>
					<div class="list_price_num yuan_price">￥<span>${items.originalPrice}</span></div>
					<div class="list_sales_num">销量<span>${items.basicsNum}</span></div>
					<div class="clear"></div>
				</div>
			</li>
			</c:forEach>
			<div class="clear"></div>
		</ul>
		<div class="otherBtns">
			<c:choose>
				<c:when test="${page.pageNo != page.totalPages}">
					<a class="nextpage" value="点击加载更多"  href="${path}/frontEndIndex?pageNo=${page.nextPageNo}">点击加载更多</a>
				</c:when>
				<c:otherwise>
					<%--<a class="nextpage" value="点击加载更多" >点击加载更多</a>--%>
				</c:otherwise>
			</c:choose>
		</div>
		<%--<button id="paging">点击加载更多</button>--%>
	</div><!-- content_wrap -->
	
	<div class="footer_copyright">
		<p>苏州知行合一网络科技有限公司提供技术支持</p>
	</div><!-- footer_copyright -->

<script type="text/javascript">
            $(document).ready(function () {
                var ajaxStatus = true;

                $("#paging").click(function () {
                    if(ajaxStatus){
                        ajaxStatus = false;
                        var current_page = $("#current_page").val();
                        var total_page = $("#total_page").val();
                        var next_page = parseInt(current_page)+1;
                        var aid = $("#aid").val();
                        if(next_page > total_page) {
							$("#paging").hide();
                            return false;
                        }

                        var params = {
                            page_index:next_page,
                            aid:aid
                        };
                        $.ajax({
                            url:" ",
                            type:"get",
                            data:params,
                            success:function(data){
                                $("#votelist").append(data);
                                $("#current_page").val(next_page);
                                ajaxStatus = true;
                            },
                            error:function(){
                                alert('网络故障，请稍后重试!');
                                ajaxStatus = true;
                            }
                        });
                    }
                });

                
            });
        </script>
</body>
</html>